<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%@page import="com.base.model.MessageInfo"%>
    <%@page import="java.util.*"%>
    <%if(session.getAttribute("userName")==null){ 
    	response.sendRedirect(request.getContextPath()+"/pages/admin/login.jsp");
    }
    List<MessageInfo> results = (List<MessageInfo>)request.getAttribute("list");
    %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>留言信息页</title>
	<link href="<%=request.getContextPath() %>/css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
 
<!-- 添加留言 -->
<script language="javascript"> 
	function view(id){
		document.form1.action = "MessageServlet.do?method=load&messageId="+id;
		document.form1.submit();
	}
	function del(id){
		document.form1.action = "MessageServlet.do?method=delete&messageId="+id;
		document.form1.submit();
	}
</script>

<FORM name="form1" method="post">
	<div style="float:left;margin-top:10px;height:250px;overflow: auto;" >
			<table border="1" cellpadding="0" cellspacing="0" class="Listing"  style="float:left;">
				<tr><th>主题</th>
						<th>内容</th>
						<th>留言人</th>
						<th>留言时间</th>
						<th>是否已查看</th>
						<th>操作</th></tr>
				<%
					if(results != null && results.size()>0){
						for(int i = 0; i < results.size(); i++){
							MessageInfo info = (MessageInfo)results.get(i);
							%>
							<tr>
							<td><a id="<%=info.getMessageId() %>" href="javascript:view('<%=info.getMessageId() %>');"><%=info.getMessageSubject() %></a></td>
							<td><%=info.getMessageContent() %></td>
							<td><%=info.getContactName() %></td>
							<td><%=info.getCreateTime() %></td>
							<td>
							<%if("0".equals(info.getMessageViewFlag().trim())){ %>
							<font color="red">未查看</font>
							<%
								}
								else{
							%>
							<font color="blue">已查看</font>
							<%
								} 
							%>
							</td>
						 	<td nowrap="nowrap" align="center">
						 		<input type="button" value="删除" onclick="del('<%=info.getMessageId() %>');" />
						 	</td></tr>
							<%
						}
					}
				%>
			</table>
	</div>
  </FORM>

</body>
</html>